from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter
from meiduo_admin.home import views
from meiduo_admin.user import user_views
from meiduo_admin.good import sku_views,spu_views,spec_views,spec_options_views,sku_images_views
from meiduo_admin.order import order_views
from meiduo_admin.system import permission_views,group_permission_views,admin_permission_views
from meiduo_admin.channel import channel_views,brand_views


urlpatterns = [
    # ---------------首页部分
    url(r'^authorizations/$',obtain_jwt_token),
    url(r'^statistical/total_count/$',views.UserTotalCountView.as_view()),
    url(r'^statistical/day_increment/$',views.UserIncrementCountView.as_view()),
    url(r'^statistical/day_active/$',views.UserDayActiveCountView.as_view()),
    url(r'^statistical/day_orders/$',views.UserOrderCountView.as_view()),
    url(r'^statistical/month_increment/$',views.UserMonthIncrementCountView.as_view()),
    url(r'^statistical/goods_day_views/$',views.UserGoodsDayView.as_view()),
    # ---------------首页部分

    # ---------------用户部分
    url(r'^users/$',user_views.UserView.as_view()),
    # ---------------用户部分

    # ---------------商品部分
    # url(r'^skus/$',views.SKUView.as_view({"get":"list"})),
    url(r'^skus/categories/$',sku_views.SKUCategoryView.as_view()),
    url(r'^goods/simple/$',sku_views.GoodSimpleView.as_view()),
    url(r'^goods/(?P<spu_id>\d+)/specs/$',sku_views.SKUGoodSpecs.as_view()),
    # ---------------商品部分

    # 4.spu
    url(r'^goods/brands/simple/$',spu_views.SPUBrandSimpleView.as_view()),
    url(r'^goods/channel/categories/$',spu_views.SPUCategoryView.as_view()),
    url(r'^goods/channel/categories/(?P<category_id>\d+)/$',spu_views.SPUCategorySubView.as_view()),
    url(r'^goods/images/$',spu_views.SPUImageUploadView.as_view()),

    # 6.新增规格显示
    url(r'^goods/specs/simple/$',spec_options_views.OptionSpecView.as_view()),

    # 7.图片列表新增
    url(r'^skus/simple/$',sku_images_views.SKUImageViewSet.as_view({"get":"simple"})),

    # 8.商品订单状态修改
    # url(r'^orders/(?P<pk>\w+)/status/$',order_views.OrderViewSet.as_view({"put":"status"})),

    # 9.获取权限类型
    url(r'^permission/content_types/$',permission_views.PermissionContentTypeView.as_view()),

    # 10.获取用户权限表数据
    url(r'^permission/simple/$',group_permission_views.PermissionSimpleView.as_view()),

    # 11.用户组权限表数据
    url(r'^permission/groups/simple/$',admin_permission_views.GroupPermissionView.as_view()),

    # 12.添加商品表类型
    url(r'^goods/channel_types/$',channel_views.ChannelTypeView.as_view()),

    # 13.添加商品
    url(r'^goods/categories/$',channel_views.ChannelCategoriesView.as_view())

]
# 13.商品品牌
router = DefaultRouter()
# 2.注册视图集
router.register(r'goods/brands',brand_views.BrandViewSet,base_name="brands")
# 3.添加路由到urlpatterns
urlpatterns += router.urls


# 12.商品分级表
router = DefaultRouter()
# 2.注册视图集
router.register(r'goods/channels',channel_views.ChannelViewSet,base_name="admins")
# 3.添加路由到urlpatterns
urlpatterns += router.urls


# 11.管理员权限
router = DefaultRouter()
# 2.注册视图集
router.register(r'permission/admins',admin_permission_views.AdminPermissionViewSet,base_name="admins")
# 3.添加路由到urlpatterns
urlpatterns += router.urls


# 10.用户组权限
# 1.创建路由
router = DefaultRouter()
# 2.注册视图集
router.register(r'permission/groups',group_permission_views.GroupPermissionViewSet,base_name="groups")
# 3.添加路由到urlpatterns
urlpatterns += router.urls



# 9.permission/perms/
# 1.创建路由
router = DefaultRouter()
# 2.注册视图集
router.register(r'permission/perms',permission_views.PermissionViewSet,base_name="permission")
# 3.添加路由到urlpatterns
urlpatterns += router.urls



# 8.订单
# 1.创建路由
router = DefaultRouter()
# 2.注册视图集
router.register(r'orders',order_views.OrderViewSet,base_name="options")
# 3.添加路由到urlpatterns
urlpatterns += router.urls




# 7.图片库
# 1.创建路由
router = DefaultRouter()
# 2.注册视图集
router.register(r'skus/images',sku_images_views.SKUImageViewSet,base_name="options")
# 3.添加路由到urlpatterns
urlpatterns += router.urls

# 6.规格选项管理/specs/options/
# 1.创建路由
router = DefaultRouter()
# 2.注册视图集
router.register(r'specs/options',spec_options_views.SpecOptionsViewSet,base_name="options")
# 3.添加路由到urlpatterns
urlpatterns += router.urls

# 5.spec规格管理/goods/specs/
# 1.创建路由
router = DefaultRouter()
# 2.注册视图集
router.register(r'goods/specs',spec_views.SpecViewSet,base_name="specs")
# 3.添加路由到urlpatterns
urlpatterns += router.urls

# 4.spu
# 1.创建路由
router = DefaultRouter()
# 2.注册视图集
router.register(r'goods',spu_views.SPUView,base_name="goods")
# 3.添加路由到urlpatterns
urlpatterns += router.urls

# 3.sku
# 1.创建路由
router = DefaultRouter()
# 2.注册视图集
router.register(r'skus',sku_views.SKUView,base_name="skus")
# 3.添加路由到urlpatterns
urlpatterns += router.urls